namespace OptionParser
{
    using System;
    using System.Reflection;
    using System.Collections;
    using System.IO;
    
    public class InputOutputGetOptions : GetOptions
    {
        [Option ("-i", "Get data from file.")]
        public string InFile;
        
        [Option ("-o", "Output to file.")]
        public string OutFile;

        public InputOutputGetOptions()
        {
            InFile = "";
            OutFile = "";
        }
        
        public void ProcessArgs(string[] args, string extension)
        {
            base.ProcessArgs(args);
            
            // make sure we have at least an infile
            if (InFile == "" && RemainingArgs.Length < 1)
            {
                Console.Error.WriteLine("Please specify a file");
                Environment.Exit(1);
            }
            else if (InFile == "")
                InFile = RemainingArgs[0];
            
            // see if we have an outfile somewhere
            if (OutFile == "" && RemainingArgs.Length > 1)
                OutFile = RemainingArgs[1];
            else if (OutFile == "")
            {
                OutFile = Path.ChangeExtension(InFile, extension);
            }
        }
    }
}
